//
//  SearchTextField.m
//  AiShangJinFuSalesman
//
//  Created by AiShangTong on 2017/7/22.
//  Copyright © 2018年 AiShangTong. All rights reserved.
//

#import "SearchTextField.h"

@interface SearchTextField ()

@end

@implementation SearchTextField

/**
 *  控制编辑文本的位置
 */
-(CGRect)editingRectForBounds:(CGRect)bounds {
    
    CGRect inset = CGRectMake(bounds.origin.x+20, bounds.origin.y, bounds.size.width, bounds.size.height);
    if (self.text.length) {
        inset = CGRectMake(bounds.origin.x+20, bounds.origin.y-0, bounds.size.width, bounds.size.height);
    }
    if (!self.isFirstResponder) {
        inset = CGRectMake(bounds.origin.x+20, bounds.origin.y, bounds.size.width, bounds.size.height);
    }
    
    return inset;
    
}

- (CGRect)leftViewRectForBounds:(CGRect)bounds {
    
    CGRect inset = CGRectMake(ScreenWidthMao/2.f-80, 8, 20, 14);
    if (self.leftView.tag == 11 || self.text.length) {
        inset = CGRectMake(0, 8, 20, 14);
    }else if (self.leftView.tag == 10 ) {
        inset = CGRectMake(ScreenWidthMao/2.f-80, 8, 20, 14);
    }
    return inset;
}

/**
 *  控制显示文本的位置
 */
-(CGRect)textRectForBounds:(CGRect)bounds {
    
    CGRect inset = CGRectMake(ScreenWidthMao/2.f-55, bounds.origin.y, bounds.size.width, bounds.size.height);
    if (self.text.length) {
        inset = CGRectMake(bounds.origin.x+20, bounds.origin.y, bounds.size.width, bounds.size.height);
    }
    
    
    return inset;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
